package com.rui.study.algorithm.L_深入拆解JVM_InvokeDynamic;

import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles;
import java.lang.invoke.MethodType;

/**
 * @program: study
 * @description:
 * @author: Yaowr
 * @create: 2018-12-14 11:10
 **/
public class FooV8 {

    public void bar(Object o) {

    }

    public static void main(String[] args) throws Throwable {
        MethodHandles.Lookup l = MethodHandles.lookup();
        MethodType t = MethodType.methodType(void.class, Object.class);
        MethodHandle mh = l.findVirtual(FooV8.class, "bar", t);

        long curent = System.currentTimeMillis();
        for (int i = 1; i <= 2_000_000_000; i++) {
            if (i % 100_000_000 == 0) {
                long temp = System.currentTimeMillis();
                System.out.println(temp - curent);
                curent = temp;
            }
            mh.invokeExact(new FooV8(), new Object());
        }
    }
}
